import 'package:aitao_flutter/routes/routes.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pin_code_fields/pin_code_fields.dart';
import '../../common_ui/back_nav.dart';
import '../../style/box_style.dart';
import '../../style/color_style.dart';
import '../../style/edgeInsets_style.dart';
import '../../style/text_style.dart';

class YoundSetPsPage extends StatefulWidget {
  const YoundSetPsPage({super.key});

  @override
  State<YoundSetPsPage> createState() => _YoundSetPsPageState();
}

class _YoundSetPsPageState extends State<YoundSetPsPage> {
  TextEditingController editingController = TextEditingController();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: ColorStyle.whiteColor,
      appBar: BackNavigation(title: '青少年模式'),
      body: Container(
          alignment: Alignment.center,
          padding: EdgeInsetsStyle.customMargin(80, 0, 80, 100),
          child: ListView(
            children: [
              Box.vBox(60),
              Text(
                '设置密码',
                style: Styles.normalText_18,
                textAlign: TextAlign.center,
              ),
              Box.vBox30,
              PinCodeTextField(
                autoFocus: true,
                controller: editingController,
                cursorColor: ColorStyle.themeColor,
                keyboardType: TextInputType.number,
                onCompleted: (txt) {
                  debugPrint('txt:$txt');
                  editingController.text = txt;
                  Get.toNamed(Routes.youngConfirmPassPage,
                      parameters: {'password': editingController.text});
                },
                appContext: context, //context
                length: 4, //输入的长度
                onChanged: (value) {
                  editingController.text = value;
                }, //变化回调
              )
            ],
          )),
    );
  }
}
